/***************************************************************************
 *   Copyright (C) 2007 by Alexandre Masselot,,,   *
 *   alex@alex-laptop   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "utils/spectrum.h"
#include "utils/peakintensity.h"
#include "utils/spectrumpeakintensityutilities.h"

#include <iostream>
#include <algorithm>

using namespace std;
using namespace bol;

int main(int argc, char **argv){
  //one peak - with default m/z and charge mask
  string tmp="2,4 OR 7+";
  Peak p(123.456, tmp);
  cout<<"one peak (charge is set from string '"<<tmp<<"'): "<<p<<endl;
  cout<<"loop on chargelist:\n";
  for(unsigned int *c=p.charges(); *c; c++){
    cout<<"on charge="<<*c<<"\n";
  }
  
  //a simplest spectrum (Peak contians only moz)
  cout<<"------------ sort a vector of Peak ----------<<\n";
  Spectrum<Peak*> sp;
  for(int i=0; i<10; i++){
    sp.push_back(new Peak(11.1-i));
  }
  sort(sp.begin(), sp.end());
  cout<<"sorted Spectrum<Peak> (size="<<sp.size()<<")\n"<< sp;
  cout.flush();

  //an PeakIntensity, sorting it on moz and setting up intensity Rank
  cout<<"------------ sort a vector of PeakIntensity and computing peak rank ----------\n";
  Spectrum<PeakIntensity*> spi;
  spi.push_back(new PeakIntensity(1., "1+", 4.3));
  spi.push_back(new PeakIntensity(4., "2+", 2));
  spi.push_back(new PeakIntensity(2., "3+", 2.));
  spi.push_back(new PeakIntensity(9., "2,3", 2.));
  spi.push_back(new PeakIntensity(1.5, "11+ OR 17+", 9.4));
  spi.push_back(new PeakIntensity(3., "3,4,5", 1.1));

  sort(spi.begin(), spi.end());
  SpectrumPeakIntensityUtilities::computeIntensityRank(spi);

  cout<<"sorted on intensity Spectrum<Peak> (size="<<spi.size()<<")\n";
  cout<< spi;

}
